package net.pulseproject.router.config.parser;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

public class ConfigParserErrors {
	
	private final List<ParseError> errors = new LinkedList<ParseError>();
	
	void addError(ParseError error) {
		this.errors.add(error);
	}
	
	public boolean isError() {
		return this.errors.isEmpty() == false;
	}
	
	public Collection<ParseError> getErrors() {
		return this.errors;
	}
	
	public String prettyPrint() {
		if(this.isError() == false) {
			return "No errors.";
		}
		
		StringBuilder sb = new StringBuilder();
		for (ParseError error : this.errors) {
			sb.append("\n").append(error.getDescription());
		}
		
		return sb.substring(1);
	}
	
	public static class ParseError {
		private final String description;

		public ParseError(String description) {
			this.description = description;
		}

		public final String getDescription() {
			return this.description;
		}
		
	}
	
}
